package cn.otrue.patienthealthmanager.activity;

import java.util.Map;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;
import cn.otrue.patienthealthmanager.R;
import cn.otrue.patienthealthmanager.adapter.MyFragmentPagerAdpater;
import cn.otrue.patienthealthmanager.adapter.ScrollTabsAdapter;
import cn.otrue.patienthealthmanager.fragment.MessageAllFragment;
import cn.otrue.patienthealthmanager.fragment.MessageFreeAskFragment;
import cn.otrue.patienthealthmanager.fragment.MessageFreeAskReplyFragment;
import cn.otrue.patienthealthmanager.fragment.MessageGZFragment;
import cn.otrue.patienthealthmanager.fragment.MessageQAFragment;
import cn.otrue.patienthealthmanager.fragment.MessgaeWJFragment;
import cn.otrue.patienthealthmanager.view.ScrollTabView;

/**
 * 个人中心->消息中心
 * 
 * @author G
 * 
 */
public class CenterMessageActivity extends BaseActivity {
	private TextView tv_title_title;
	Map<String, String> messageData;
	private TextView tv_title_back;
	private ScrollTabView st_pat_message_head;
	private ViewPager vp_pat_message_pager;
	private ScrollTabsAdapter tabsAdapter;
	private MyFragmentPagerAdpater fragmentAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_center_message);
		initView();
	}

	private void initView() {
		initTitleBar();
		st_pat_message_head = (ScrollTabView) findViewById(R.id.st_pat_message_head);
		vp_pat_message_pager = (ViewPager) findViewById(R.id.vp_pat_message_pager);
		initAdapter();
	}

	public void initAdapter() {
		tabsAdapter = new ScrollTabsAdapter(this, 4);// 4：设置整个屏幕显示的标题个数
		tabsAdapter.add(getString(R.string.all_mesage));
//		tabsAdapter.add(getString(R.string.p_guanzhu__d));// 患者关注医生申请
//		tabsAdapter.add(getString(R.string.d_guanzhu__p));// 患者回复医生关注
		tabsAdapter.add(getString(R.string.questionnaire_adjust));// 系统消息
		tabsAdapter.add(getString(R.string.message_guanzhu));//医生回应患者关注//(现在是关注消息)
//		tabsAdapter.add(getString(R.string.p_huiying_d_yaqing));//患者回应医生邀请
		tabsAdapter.add(getString(R.string.question_check));//问卷调查
		tabsAdapter.add(getString(R.string.ask_free));//免费问
		tabsAdapter.add(getString(R.string.d_invite_guanzhu));//询问回复
		st_pat_message_head.setAdapter(tabsAdapter);
		fragmentAdapter = new MyFragmentPagerAdpater(getSupportFragmentManager());
		fragmentAdapter.addFragment(MessageAllFragment.newInstance());//
//		fragmentAdapter.addFragment(MessagePGZDFragment.newInstance());// 患者关注医生申请
//		fragmentAdapter.addFragment(MessagePHFDGZragment.newInstance());// 患者回复医生关注
		fragmentAdapter.addFragment(MessageQAFragment.newInstance());// 系统消息
		fragmentAdapter.addFragment(MessageGZFragment.newInstance());//医生回应患者关注//(现在是关注消息)
//		fragmentAdapter.addFragment(MessagePHYDIFragment.newInstance());//患者回应医生邀请 
		fragmentAdapter.addFragment(MessgaeWJFragment.newInstance());//问卷调查
		fragmentAdapter.addFragment(MessageFreeAskFragment.newInstance());//免费询问
		fragmentAdapter.addFragment(MessageFreeAskReplyFragment.newInstance());// 询问回复
		vp_pat_message_pager.setAdapter(fragmentAdapter);
		st_pat_message_head.setViewPager(vp_pat_message_pager);
		vp_pat_message_pager.setOffscreenPageLimit(4);//
		vp_pat_message_pager.setCurrentItem(0);
	}

	public void initTitleBar() {
		tv_title_title = (TextView) findViewById(R.id.tv_title_title);
		tv_title_title.setText(getString(R.string.newscenter));

		tv_title_back = (TextView) findViewById(R.id.tv_title_back);
		tv_title_back.setVisibility(View.VISIBLE);
		tv_title_back.setOnClickListener(this);
	}

	@Override
	public void onClick(View arg0) {
		switch (arg0.getId()) {
		case R.id.tv_title_back:
			finish();
			break;

		default:
			break;
		}
	}

}
